package com.group01.service.impl;

import com.group01.result.Result;
import com.group01.service.UploadService;
import com.group01.utils.AliOSSUtils;
import lombok.SneakyThrows;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Description 文件上传实现类
 * @Author 翟玉龙
 * @Date 2024/6/21
 */
@Service
public class UploadServiceImpl implements UploadService {

    /**
     * 文件上传工具类
     */
    private final AliOSSUtils aliOSSUtils;

    public UploadServiceImpl(AliOSSUtils aliOSSUtils) {
        this.aliOSSUtils = aliOSSUtils;
    }

    /**
     * 阿里云对象存储
     * @param img 文件
     * @return {@link Result }<{@link String }>
     */
    @SneakyThrows
    @Override
    public Result<String> upload(MultipartFile img) {
        return Result.success("上传成功", aliOSSUtils.upload(img));
    }
}
